import {Injectable} from '@angular/core';
import {Category} from '../../models/Category';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';
import {Observable} from "rxjs/Observable";


/*
 Generated class for the CategoryProvider provider.

 See https://angular.io/docs/ts/latest/guide/dependency-injection.html
 for more info on providers and Angular 2 DI.
 */
@Injectable()
export class CategoryProvider {
  private categoryUrl = 'http://www.ezbe.cn/api/categories';  // URL to web api
  constructor(private http: Http) {
  }

  getCategories(): Observable<Category[]> {
    return this.http.get(this.categoryUrl)
      .map(response => response.json().data as Category[])
  }
}
